<template>
	<view>
		<uni-list>
			<!-- #ifdef APP-PLUS -->
			<uni-list-item title="分享好友" @click="shareFriend" thumb="/static/icons/fenxianghaoyou.png"></uni-list-item>
			<!-- #endif -->
			<uni-list-item title="赞赏支持" @click="toZanShangZhiChi" thumb="/static/icons/zanshangzhichi.png"></uni-list-item>
			<uni-list-item title="我的收藏" @click="toCollection" thumb="/static/icons/shoucang.png"></uni-list-item>
			<uni-list-item title="时间戳" @click="toTime" thumb="/static/icons/shijian.png"></uni-list-item>
			<!-- #ifndef H5 -->
			<uni-list-item title="意见反馈" thumb="/static/icons/yijianfankui.png" openType="feedback"></uni-list-item>
			<!-- #endif -->
			<!-- #ifdef MP-WEIXIN -->
			<uni-list-item title="联系客服" thumb="/static/icons/lianxikefu.png" openType="contact"></uni-list-item>
			<!-- #endif -->
			<uni-list-item title="关于我们" @click="toAbout" thumb="/static/icons/guanyuwomen.png"></uni-list-item>
			<uni-list-item v-if="user" title="退出登录" @click="toUnLogin" thumb="/static/icons/tuichu.png"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
import userApi from '@/api/myUser.js';
export default {
	data() {
		return {
			user: uni.getStorageSync('user')
		};
	},
	methods: {
		// 跳转到关于我们
		toAbout() {
			uni.navigateTo({
				url: '/pages/about/about'
			});
		},
		// 跳转到赞赏支持
		toZanShangZhiChi() {
			uni.navigateTo({
				url: '/pages/zan-shang-zhi-chi/zan-shang-zhi-chi'
			});
		},
		// 跳转到我的收藏
		toCollection() {
			var validate = '';
			userApi.validateUser().then(res => {
				validate = res.data.validateLogin;
				console.log(validate);
				if (validate === '1') {
					// 已登录
					uni.navigateTo({
						url: '/pages/my-collection/my-collection'
					});
				} else {
					uni.showToast({
						title: '当前未登录，请先登录在访问！',
						icon: 'none'
					});
				}
			});
		},
		// 跳转到时间戳
		toTime() {
			uni.navigateTo({
				url: '/pages/time-line/time-line'
			});
		},
		shareFriend() {
			// 分享好友
			uni.share({
				provider: 'weixin',
				type: 1,
				title: '欢迎进入闲言博客，这里是一个狗屁不通的博主！！！',
				summary: '我是摘要！！！！！',
				fail(err) {}
			});
		},
		// 退出登录
		toUnLogin() {
			userApi.closeUser().then(res => {
				uni.clearStorage();
				uni.clearStorageSync();
				uni.removeStorage({
					key: 'user'
				});
				uni.removeStorage({
					key: 'Authorization'
				});
				uni.showToast({
					title: res.msg,
					icon: 'none'
				});
				uni.reLaunch({
					url: '/pages/mine/mine'
				});
			});
		}
	}
};
</script>

<style></style>
